1. Field of the Invention
The present invention relates to a video codec, and in particular to a variable length coding method in a video codec.
2. Description of the Background Art
In general, a signal to be transmitted or stored is described as columns of several symbols. Indicating each symbol as a code having a certain length is called coding. Herein, indicating each symbol as a code having the same length is called a fixed length coding, and indicating each symbol as a code having a different length is called VLC (variable length coding).
In the VLC, when each symbol is described with a code having a different length, a shorter length code is allocated to a symbol of comparatively high occurrence frequency, and a longer length code is allocated to a symbol of comparatively low occurrence frequency. Accordingly, a signal can be described with a less bit quantity in comparison with that of the fixed length coding allocating the same length code to all symbols.
In comparison with the fixed length coding, the VLC is efficient in compressing information quantity of a signal, however it may be inefficient in radio circumstances in which channel errors occur frequently. That is, when a code describing a certain symbol is affected by influences of a channel error, only a pertinent symbol is lost in the fixed length coding. However, in the VLC, because each code about each symbol has an inherent length, not only a pertinent symbol but also consecutive following codes may be lost. Accordingly, various methods for detecting a channel error in radio environment have been presented in a VLC process of a H.263 video codec as defined by the 3GPP (3rd generation partnership program) Standard.
FIG. 1 is a block diagram illustrating a general video communication system. As depicted in FIG. 1, the video communication system is largely divided into a transmitting unit and a receiving unit. The transmitting unit includes a camera 101 and a H.263 encoder 102 for encoding pictures photographed by the camera 101 into H.263 and transmitting them wirelessly. Accordingly, pictures photographed by the camera 101 are encoded by the H.263 encoder 102 and are transmitted to the receiving unit through a radio channel.
The receiving unit includes a video decoder 103, an error detector 104, an error corrector 105 and a display 106. The H.263 decoder 103 decodes a H.263 bit stream transmitted through the radio channel into MPEG or H.263 format, and the error detector 204 detects a channel error from the decoding signal. Accordingly, the error corrector 105 corrects or conceals the detected error and displays it through the display 106. Herein, the error is corrected by using a correctly decoded previous picture portion or a present picture portion.
In general, in order to eliminate spatial and temporal redundancy, the H.263 encoder respectively uses a DCT (discrete cosine transform) method and a MC (motion compensation) method. In the DCT method for eliminating correlation of data through two-dimensional spatial conversion, spatial conversion is performed about a picture by a 8 pixel×8 pixel block unit. Herein, because the spatial-converted data tend to gather together to one side, they are transmitted after being quantized.
In temporally consecutive pictures, motion of a person or an object is mainly shown on the central portion of a screen. By using the characteristic, temporal redundancy is eliminated in the MC method. In more detail, by filling an unchanged portion (or a portion having the minimum change) with a similar portion taken from a previous picture, it is possible to minimize data quantity to be transmitted. As described-above, finding the most similar macroblock between pictures is called ME (motion estimation), and describing degree of motion as displacement is called motion vector.
FIG. 2 is a block diagram illustrating a construction of a general H.263 encoder. As depicted in FIG. 2, when a present macroblock of an input picture is not similar to any macroblock of a previous picture, a coding controller 202 controls the video communication system so as to be in an Intra mode, when there is a similar macroblock, the coding controller 202 controls the video communication system so as to be in an Inter mode. In the Intra mode, a first switch 201 outputs an input picture to a DCT unit 204 according to a mode control signal outputted from the coding controller 202. In the inter mode, the first switch 201 outputs an input picture to a compensator 210.
If a determined mode is the Intra mode, an input picture is inputted to a VLC 203 through a DCT unit 204 and a quantizer 205 regardless of a previous picture, and the VLC 203 codes the inputted picture by using a mode control signal outputted from the coding controller 202 and a quantization parameter.
On the other hand, when a determined mode is the Inter mode, a previous picture restored through an inverse quantizer 206 and an inverse DCT 207 is stored in a frame buffer 209. By using the previous picture stored in a frame buffer 209 and the present input picture received through the first switch 201, a motion estimator 211 searches the most similar macroblock (of a previous picture) with a present macroblock. A motion compensator 210 compensates the macroblock according to a motion vector outputted from the motion estimator 211, and a first subtracter 200 outputs the difference between the present macroblock and the motion-compensated macroblock. Accordingly, a difference picture is finally encoded in the VLC 203 through the DCT unit 204 and the quantizer 205 and is transmitted.
A second switch 212 outputs the motion-compensated macroblock to an adder 208. The adder 208 adds the motion-compensated macroblock to the previous picture and outputs it to the frame buffer 209. After sampling input data by a 8×8 unit, the input data is DCT-converted in the DCT unit 204, and conversion coefficients are quantized in the quantizer 205 according to a compression ratio. In the quantized data, the VLC 203 encodes data of comparatively high occurrence frequency into a small codeword, the VLC 203 encodes data of comparatively low occurrence frequency into a long codeword, and accordingly a final data compression effect can be obtained. In the coding method, in order to obtain high compression ratio and maximize efficiency of coding, a method for performing coding independently by macroblock units is used.
FIG. 3 shows a H.263 bit stream. The H.263 bit stream outputted from the VLC 205 is divided into four layers, a block layer, a macroblock layer, a GOB (group of block) layer and a picture layer. The block layer consists of 8×8 pixels and is the lowest layer. The macroblock layer consists of four luminance blocks and two chrominance blocks. In addition, the GOB block consists of plural macroblock layers (nine macroblock layers in case of a QCIF (quarter common intermediate format) size), and the picture layer consists of plural (nine in case of the QCIF size) GOB layers.
FIG. 4 is a block diagram illustrating the macroblock layer of FIG. 3. The macroblock layer is largely divided into a header portion and a block data portion. The header portion includes a COD (coded macroblock indication) flag for indicating coding or non-coding of a macroblock; a MCBPC (macroblock type & coded block pattern for chrominance) flag having coding pattern information about a macroblock mode and a chrominance block; a CBPY (coded block pattern for luminance) flag having coding pattern information about a luminance block; a DQUANT (differential value of quantization parameter) flag having a quantization step size, namely, compression degree information.
Also included in the MB header is a MVD (motion vector data) flag; and block data having result information (texture) by DCT-quantization process by each block. The MVD is not a motion vector value itself of a present macroblock but a difference between a motion vector of the present macroblock and an estimated motion vector, and it is for improving coding efficiency by reducing a bit quantity.
The coding process in accordance with the related art is provided below with reference to the macroblock layer and accompanying FIG. 5. First, on the basis of a mode control signal received from the coding controller 202, the VLC 203 determines whether a picture type of a frame including a present macroblock is a P-picture (i.e., Inter Picture) or an I-picture (i.e., Intra Picture) as shown at step S501. If it is a P-picture, a certain value is written in the COD flag as shown at step S502. When there is no motion information in the present macroblock and all six blocks do not have texture information (as ‘0’), the COD flag is ‘1’. Except, if the COD flag is ‘0’ as shown at step S503.
Accordingly, when the COD flag is ‘1’, then a next macroblock is coded. However, when the COD flag is ‘0’, then the following steps are performed. In addition, when it is the I-picture in the judgement result, the MCBCP flag and the CBPY flag are written without writing the COD flag as shown at steps S504 and S505. Herein, the MCBPC flag indicates a format of the macroblock and a pattern about two color differential signal blocks, and the CBPY flag indicates a pattern about four brightness signal blocks. The pattern respectively indicates existence of texture information about six blocks including color difference and brightness in the macroblock.
Afterward, the DQUANT flag is written. The DQUANT flag is for showing a difference between a previously written QP and a present macroblock QP, and it is used for adjusting compression degree in the coding control unit 202. Accordingly, when the macroblock mode is in the Inter mode or the Intra mode, because DQUANT is 0, it is skipped without being written as shown at steps S506 and S507.
Afterward, a motion vector difference value is written. Herein, motion vector exists only in the Inter macroblock, and it shows how far the nearest previous frame is separated from the present macroblock in x and y directions. In the video coding, instead of coding the motion vector as it is, a value different from a predicted motion vector is coded. It is called a MVD. Accordingly, in cases except the Intra mode macroblock, the MVD flag has to be written. However, in the Intra mode macroblock, there is no need to write as shown at steps S508 and S509.
As described above, after passing the coding process in the encoder, when the coded macroblock is transmitted through a channel, a certain receiver (not shown) is received it and decodes it.
In general, in the H.263 decoder, when a symbol about a certain bit stream does not exist in a code book or a code table (invalid code), it is detected as an error. However, in the error detecting method, when an error-occurred bit stream exists in a code book accidentally, it is impossible to find an accurate error occurrence position.
For example, when an error occurs in a bit stream actually, because misconception probability is far more great than “invalid code” judgement probability, error may not be detected in the conventional error detecting method using the code book, although an error is detected, it may be detected always later than an actual error occurrence.
In a channel error occurrence, “invalid code” occurrence probability in the H.263 decoder is the probability in which a code word not in the code book occurs.                MCBPC code table for P picture: 0.110%        MCBPC code table for I picture: 1.37%        CBPY code table: 3.125%        MVD code table: 0.061%        TCOEF (quantized transform coefficient) code table: 0.195%        
As described above, in the detecting method using the code book, a main cause of detection error occurrence by a macroblock unit is an 1 bit COD flag as initial information about a macroblock. Herein, the COD flag indicates whether a macroblock is coded, when a certain macroblock is almost similar to a macroblock of a previous picture, the COD flag is set as ‘1’, and texture information is transmitted without being coded. It is mainly applied for a macroblock at a background portion in which there is no motion in a picture.
Accordingly, when the receiver misunderstands a value of the COD flag, a detection error can occur greatly. In more detail, because of motion of the camera 101, when a present picture is not similar to a previous picture, a COD flag of all macroblocks of the present picture is set as ‘0’, and texture information and motion information are coded-transmitted.
However, when an error occurs in a certain macroblock of the coded picture, if the H.623 decoder 103 of the receiver does not detect an error-occurred macroblock, it loses synchronization starting from a next macroblock, and accordingly it reads a COD wrong.
And, when a COD flag value of a macroblock losing synchronization is ‘1’ consecutively, an error of a macroblock as the number of ‘1’ can not be detected, due to that, a macroblock is decoded wrong, and accordingly detection error is increased as the number of macroblocks.